//
//  STGoodsTableViewCell.m
//  赛拓
//
//  Created by 王磊 on 7/30/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STGoodsTableViewHeaderCell.h"
#import "STCommodityBean.h"
@interface STGoodsTableViewHeaderCell()
@property (nonatomic ,strong) UIImageView *goodsImageView;

@property (nonatomic ,strong) UILabel *goodsNameLabel;

@property (nonatomic ,strong) UILabel *detailLabel;

@property (nonatomic ,strong) UILabel *companyLabel;
@end
@implementation STGoodsTableViewHeaderCell


- (void)configSubViews {
    [super configSubViews];
    
    self.backgroundColor = ST_WHITE_COLOR;
    
    UIImageView *goodsImageView = [[UIImageView alloc]init];
    
    self.goodsImageView = goodsImageView;
    
    [self addSubview:goodsImageView];
    
    UILabel *goodsNameLabel = [[UILabel alloc]init];
    
    goodsNameLabel.font = ST_13_FONT;
    
    self.goodsNameLabel = goodsNameLabel;
    
    [self addSubview:goodsNameLabel];
    
    UILabel *detailLabel = [[UILabel alloc]init];
    
    self.detailLabel = detailLabel;
    
    detailLabel.font = ST_13_FONT;
    
    [self addSubview:detailLabel];
    
    UILabel *companyLabel = [[UILabel alloc]init];
    
    companyLabel.font = ST_13_FONT;
    
    self.companyLabel = companyLabel;
    
    [self addSubview:companyLabel];
    
    self.selectionStyle = UITableViewCellSelectionStyleGray;
}
- (void)updateData:(id)data {
    
    STCommodityBean *goods = data;
    
    self.companyLabel.text = goods.company;
    
    self.goodsNameLabel.text = goods.name;
    
    [self.goodsImageView set_BGBannerImageViewWithString:goods.imgUrl];
}

#define margin 10 * ST_RATE
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.goodsImageView.frame = CGRectMake(margin, margin, self.k_height - margin * 2, self.k_height - margin * 2);
    
    self.goodsNameLabel.frame = CGRectMake(margin + CGRectGetMaxX(self.goodsImageView.frame), margin * 2, self.k_width - CGRectGetMaxX(self.goodsImageView.frame) - margin, 30 * ST_RATE);
    
    self.companyLabel.frame = CGRectMake(margin + CGRectGetMaxX(self.goodsImageView.frame), margin + CGRectGetMaxY(self.goodsNameLabel.frame), self.k_width - CGRectGetMaxX(self.goodsImageView.frame) - margin, 30 * ST_RATE);
    
    self.detailLabel.frame = CGRectMake(margin + CGRectGetMaxX(self.goodsImageView.frame), margin + CGRectGetMaxY(self.detailLabel.frame), self.k_width - CGRectGetMaxX(self.goodsImageView.frame) - margin, 30 * ST_RATE);
}

- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];
}
@end
